package com.yanqu.road.server.logic.activity.condition.treasure;

import com.yanqu.road.entity.activity.ActivityConditionInfo;
import com.yanqu.road.entity.activity.ActivityInfo;
import com.yanqu.road.entity.enums.eGamePlayerEventType;
import com.yanqu.road.entity.task.args.HolidayActivityArgs;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.task.TaskModule;
import com.yanqu.road.server.logic.activity.BaseActivityData;
import com.yanqu.road.server.logic.activity.condition.BaseNewRankActivityCondition;

public class TreasureActivityScoreCrossRankCondition extends BaseNewRankActivityCondition {

    public TreasureActivityScoreCrossRankCondition(ActivityInfo activityInfo, ActivityConditionInfo activityConditionInfo, BaseActivityData baseActivityData) {
        super(activityInfo, activityConditionInfo, baseActivityData);
    }

    @Override
    public void addTrigger(GamePlayer player) {
        player.getModule(TaskModule.class).getGameEvent().addListener(eGamePlayerEventType.TreasureActivityScoreCrossRank.getValue(), handle);
    }

    @Override
    public void removeTrigger(GamePlayer player) {
        player.getModule(TaskModule.class).getGameEvent().removeListener(eGamePlayerEventType.TreasureActivityScoreCrossRank.getValue(), handle);
    }

    @Override
    protected void player_BoardLevelHandle(Object object) {
        HolidayActivityArgs args = (HolidayActivityArgs) object;
        if (null != args) {
            if (null != activityInfo && activityInfo.getChildType() == args.getActivityChildType()) {
                if (args.getValue().compareTo(getValue()) > 0) {
                    setValue(args.getValue());
                    rankChange();
                }
            }
        }
    }
}
